<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <style>
        *{
            margin: 0;
            padding: 0;
        }
        header{
            width: 1140px;
            height: 50px;
            background-color: #eee;
            margin: 100px auto 0;
        }
        ul{
            overflow: hidden;
            height: 100%;
            position: relative;
        }
        li{
            list-style: none;
            float: left;
            width: 8.3333333%;
            height: 100%;
            text-align: center;
            line-height: 50px;
            box-sizing: border-box;
        }
        li span{
        	display: inline-block;;
        }
        li:hover{
            cursor: pointer;
        }
        .active{
            color: #e804e8;
        }
        
        ._bottom{
            position: absolute;
            left: 0px;
            bottom: 0px;
            height: 2px;
            background: #E804E8;
        }

    </style>

</head>
<body>
    <header>
        <ul>
			<li class="active"><span>首页</span></li>
			<li><span>档案</span></li>
			<li><span>详情</span></li>
			<li><span>百科</span></li>
			<li><span>音乐</span></li>
			<li><span>电影</span></li>
			<li><span>首页</span></li>
			<li><span>档案</span></li>
			<li><span>详情detail</span></li>
			<li><span>百科</span></li>
			<li><span>音乐Music</span></li>
			<li><span>电影</span></li>
			<div class="_bottom"></div>
        </ul>
    </header>

    <script src="js/jquery.min.js"></script>
    <script>
    	var liWidth  = $("li").first().width();//每个li的宽度；
        var spanWidth = $("li").first().children().width();//每个span的宽度；
        var leftMove = parseInt(liWidth - spanWidth) / 2 ;
    	$("._bottom").css({
    		"left":leftMove,
    		"width":spanWidth
    	});
    	//点击li的时候，底部横岗的长度;
        $('li').click(function(){
        	var index = $(this).index();
        	var liWidth  = $(this).width();//每个li的宽度;
        	var spanWidth = $(this).children().width();//每个span的宽度;
        	var leftMove = liWidth * index + parseInt(liWidth - spanWidth) / 2;
            $(this).addClass('active').siblings().removeClass('active');
            $("._bottom").css({"width":spanWidth});
            $("._bottom").animate({"left":leftMove});
        });
		
    </script>
</body>
</html>